const { ipcMain } = require("electron");
const Types = require("../../const/eventName");
const contextHandle = require("./contextMenuHandle");
const { createSettingWindow, closeSettingWindow } = require("./windowEvent.js");
const {
  openFileDialog,
  getDocPath,
  getFileStoreFiles,
  updateFilesToFileStore,
} = require("./fileHandle");

const {
  openSettingDia,
  getSettingPath,
  setSettingPath,
  getOssConfig,
  setOssConfig,
} = require("./settingHandle");

const { uploadFileToOss, deleteOssFile } = require("./ossHandle");

module.exports = function () {
  // 鼠标右键菜单
  ipcMain.on(Types.OPENCONTEXTMENU, contextHandle);
  // 导入文件
  ipcMain.on(Types.OPENFILEDIALOG, openFileDialog);
  // 获取存储的文件
  ipcMain.on(Types.GETFILESTOREFILES, getFileStoreFiles);
  // 更新存储的文件
  ipcMain.on(Types.UPDATEFILESTOREFILES, updateFilesToFileStore);
  // 获取文件存储位置
  ipcMain.on(Types.GETDOCPATH, getDocPath);

  // 打开/关闭设置窗口
  ipcMain.on(Types.SHOWSETTINGWINDOW, createSettingWindow);
  ipcMain.on(Types.CLOSESETTINGWINDOW, closeSettingWindow);

  //设置选择保存位置
  ipcMain.on(Types.GETSETTINGDOCPATH, getSettingPath);
  ipcMain.on(Types.SAVESETTINGPATH, setSettingPath);
  ipcMain.on(Types.OPENSETTINGDIA, openSettingDia);

  ipcMain.on(Types.GETOSSCONFIG, getOssConfig);
  ipcMain.on(Types.SETOSSCONFIG, setOssConfig);

  // oss文件操作
  ipcMain.on(Types.OSSUPLOAD, uploadFileToOss);
  ipcMain.on(Types.OSSDELETE, deleteOssFile);
};
